package com.bdqn.demo01.utils;

import redis.clients.jedis.Jedis;

//Redis的工具类
public class RedisUtil {
    public static Jedis redisConnection() {
        Jedis jedis = new Jedis("localhost", 6379);
        return jedis;
    }


    public String setKey(String key, String value) {
        //redis.set(key,value)
        return RedisUtil.redisConnection().set(key, value);
    }


    public String setKey(String key, String value, int expire) {
        //redis.set(key,value,ex,expire)
        return RedisUtil.redisConnection().setex(key, expire, value);
    }


    public String getKey(String key) {
        return RedisUtil.redisConnection().get(key);
    }
}
